import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:fixnum/fixnum.dart' as $fixnum;
import 'package:get/get.dart';

import '../../../../../../lib_baseview/utils/screen_utils.dart';

class RoomRankPage extends StatefulWidget {
  final $fixnum.Int64 channelId;
  // final RoomRankTypeEnum displayType;

  const RoomRankPage({
    super.key,
    required this.channelId,
    // this.displayType = RoomRankTypeEnum.online,
  });

  @override
  State<StatefulWidget> createState() => _State();

  static Future? bottomShow($fixnum.Int64 channelId
      // RoomRankTypeEnum displayType = RoomRankTypeEnum.online,
      ) {
    return Get.bottomSheet(
        RoomRankPage(
          channelId: channelId,
          // displayType: displayType,
        ),
        isScrollControlled: true,
        settings: RouteSettings(name: '/RoomRankPage'));
  }
}

class _State extends State<RoomRankPage> with TickerProviderStateMixin {
  late TabController _tabController;
  // late List<RoomRankTypeEnum> _rankTypeEnums;

  @override
  void initState() {
    super.initState();
    _initRankTypes();
    int initIndex = 0;
    if (initIndex < 0) initIndex = 0;
    _tabController =
        TabController(initialIndex: initIndex, length: 1, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      height: ScreenUtils.ins.screenHeight * 0.75,
      decoration: const BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadiusDirectional.only(
              topStart: Radius.circular(24), topEnd: Radius.circular(24))),
      child: Column(
        mainAxisSize: MainAxisSize.max,
        children: [
          SizedBox(height: 12.h),
          // SizedBox(
          //   height: 36.h,
          //   child: JRGradientTabBar(
          //     titles: _rankTypeEnums.map((e) => e.title).toList(),
          //     controller: _tabController,
          //   ),
          // ),
          SizedBox(height: 10.h),
          // Expanded(
          //   child: ExtendedTabBarView(
          //     controller: _tabController,
          //     children: _rankTypeEnums.map<Widget>((e) {
          //       switch (e) {
          //         case RoomRankTypeEnum.online:
          //           return UserListOnlinePage();
          //         case RoomRankTypeEnum.trueLove:
          //           return KeepAliveWrapper(
          //               child: TrueLoveRankListPage(
          //             channelId: widget.channelId,
          //             inRoom: true,
          //           ));
          //         case RoomRankTypeEnum.cash:
          //         case RoomRankTypeEnum.charm:
          //           return RoomRankSubPage(
          //               rankTypeEnum: e, channelId: widget.channelId);
          //         case RoomRankTypeEnum.admin:
          //           return UserListAdminPage();
          //         case RoomRankTypeEnum.kick:
          //           return UserListKickPage(
          //             rid: widget.channelId.toInt(),
          //           );
          //       }
          //     }).toList(),
          //   ),
          // )

          Text('Expanded'),
        ],
      ),
    );
  }

  void _initRankTypes() {
    // _rankTypeEnums = RoomRankTypeEnum.values.toList();
    // if ((RootProxyModel.instance?.channel?.role.value ?? 0) <=
    //     RtcUserRole.Guest.value) {
    //   _rankTypeEnums
    //       .removeWhere((element) => element == RoomRankTypeEnum.admin);
    //   _rankTypeEnums.removeWhere((element) => element == RoomRankTypeEnum.kick);
    // }
  }
}

// extension RoomRankTypeEnumExt on RoomRankTypeEnum {
//   String get title {
//     switch (this) {
//       case RoomRankTypeEnum.online:
//         return T.current!.online_audience;
//       case RoomRankTypeEnum.trueLove:
//         return T.current!.true_love_rank;
//       case RoomRankTypeEnum.cash:
//         return T.current!.contribution_list;
//       case RoomRankTypeEnum.charm:
//         return T.current!.charm_list;
//       case RoomRankTypeEnum.admin:
//         return T.current!.admin;
//       case RoomRankTypeEnum.kick:
//         return T.current!.blacklist;
//     }
//   }
// }
